<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>模板字面量标签函数</title>
</head>
<body>
  <script>
    let a = 6;
    let b = 9;

    function simpleTag(strings, aValExpression, bValExpression, sumExpression) {
      console.log(strings);
      console.log(aValExpression);
      console.log(bValExpression);
      console.log(sumExpression);

      return 'foobar';
    }

    let untaggedResult = `${a} + ${b} = ${a + b}`;
    let taggedResult = simpleTag`${a} + ${b} = ${a + b}`;
    // ["", " + ", " = ", ""]
    // 6
    // 9
    // 15

    console.log(untaggedResult);  // "6 + 9 = 15"
    console.log(taggedResult);  // "foobar"
  </script>
</body>
</html>